package com.ysjy.course.service.impl;

import com.wkbb.common.base.BaseServiceImpl;
import com.wkbb.common.constants.PromptMessage;
import com.wkbb.common.dto.ResultDTO;
import com.wkbb.common.utils.DateUtil;
import com.wkbb.common.utils.RandomUtil;
import com.ysjy.course.mapper.YsSiteMapper;
import com.ysjy.course.mapper.YsTeacherMapper;
import com.ysjy.course.model.YsDeviceCount;
import com.ysjy.course.model.YsSite;
import com.ysjy.course.model.YsTeacher;
import com.ysjy.course.service.YsSiteService;
import com.ysjy.course.service.YsTeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class YsSiteServiceImpl extends BaseServiceImpl<YsSite> implements YsSiteService {

    @Autowired
    private YsSiteMapper siteMapper;

    @Autowired
    public void setMapper(YsSiteMapper mapper) {
        super.setMapper(mapper);
    }

    @Override
    public ResultDTO<Boolean> putSite(YsSite data) throws Exception {
        Date currDate = new Date();
        data.setUpdateTime(currDate);
        if (data.getId() == null){
            siteMapper.insert(data);
        }else {
            siteMapper.update(data);
        }
        return new ResultDTO<>();
    }

    @Override
    public Map<String, Object> getSiteCount(HashMap<String, Object> params) {
        return siteMapper.getSiteCount(params);
    }

    @Override
    public ResultDTO<Boolean> putDeviceTest(YsDeviceCount data) {
        siteMapper.insertDeviceTest(data);
        return new ResultDTO<>();
    }
}
